using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class BlingBling : MonoBehaviour
{
	public static bool blingbling;

	private Image image;

	private int value;

	[SerializeField]
	private int maxBlingCount;

	private void Awake()
	{
		image = GetComponent<Image>();
	}

	private void Update()
	{
		if (Time.frameCount % 600 == 0 && UnityEngine.Random.Range(0, 10) > 5 && !blingbling)
		{
			value = 0;
			maxBlingCount = UnityEngine.Random.Range(2, 10);
			blingbling = true;
			StartCoroutine(BlingBlingEffect());
		}
	}

	private IEnumerator BlingBlingEffect()
	{
		while (value < maxBlingCount)
		{
			image.enabled = !image.enabled;
			value++;
			yield return new WaitForSeconds(UnityEngine.Random.Range(0.05f, 0.1f));
		}
		image.enabled = true;
		blingbling = false;
	}
}
